package com.mo.demo;

import android.graphics.PointF;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.mo.demo.databinding.DrawBinding;
import com.zdc.broad.comm.PaintViewCallBack;
import com.zdc.broad.tools.KtUtil;

public class DrawFragment extends Fragment {
    private static final String TAG = "Drawing";
    DrawBinding binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DrawBinding.inflate(inflater, container, false);
        binding.ok.setOnClickListener(v -> {
            PointF[] ps = new KtUtil().getPoints(binding.paintView.getPath(), 60);
            //todo
        });
        binding.paintView.setCallBack(new PaintViewCallBack() {
            @Override
            public void onHasDraw() {

            }

            @Override
            public void onTouchDown() {

            }

            @Override
            public void getIntersection(float[] pos) {
                Log.e(TAG, "Path相交 X = " + pos[0] + "; y = " + pos[1]);
            }
        });
        binding.cancel.setOnClickListener(v -> {
            binding.paintView.clearAll(false);
        });
        return binding.getRoot();
    }
}
